package pattern.structure.decorator;

/**
 * @author : Rookie
 * @description :
 * @date : 2023/8/13
 */
public class DecoratorPattern {

    public static void main(String[] args) {
        Circle circle = new Circle();
        BorderDecorator decorator = new BorderDecorator(circle);
        decorator.draw();
    }
}

interface Shape {
    void draw();
}

class Circle implements Shape {

    @Override
    public void draw() {
        System.out.println("绘制一个圆形");
    }
}

class BorderDecorator implements Shape {

    private final Shape shape;

    public BorderDecorator(Shape shape) {
        this.shape = shape;
    }

    @Override
    public void draw() {
        // 调用原始的绘制图形的方法
        shape.draw();
        System.out.println("添加装饰");
    }
}
